////////////////////////////////////////
// flightUtil.h
// handling an array of objects of class 'Flight'

#ifndef FLIGHT_UTIL_H
#define FLIGHT_UTIL_H

#include "util.h"
#include "Flight.h"
using namespace std;

const int MAX_FLIGHTS = 10000;
const int MAX_MATCHING_FLIGHTS = MAX_FLIGHTS;
const int MAX = 20;
const string SENTINEL = "#";

////////////////////////////////////////
// 'readFlights' reads flight info from file 'flightFile'
//     into array 'flights' of objects of class Flight
// SENTINEL in airline position terminates the info
// returns number of read flights
// exits program if 'flightFile' not opened

int readFlights(Flight flights[], ifstream & flightFile);

////////////////////////////////////////
// 'printFlight' displays one flight information on one line

void printFlight(const Flight & flight);

////////////////////////////////////////
// 'printFlights' displays flight information in array 'flights'
//     given indices into 'flights' in array 'flightIdx'
//     with 'nIdx' indices

void printFlights(int flightIdx[], int nIdx, Flight flights[]);

////////////////////////////////////////
// 'searchFlights' searches for flights matching 'orig' and 'dest',
// stores indices of matching flights in 'flightIdx'
// return number of matching flights

int searchFlights(int flightIdx[],
    Flight flights[], int nFlights,
    const string & orig, const string & dest);

////////////////////////////////////////
// 'searchFlight' searches for flight given 'airline' and 'flightNum'
//     in array 'flights' with 'nFlights' flights
// return index into 'flights' of matching flight
// or -1 if not found

int searchFlight(Flight flights[], int nFlights,
    const string & airline, int flightNum);

////////////////////////////////////////
// 'sortFlightIdx' sorts indices 'flightIdx' with 'nIdx' indices,
//     indices are into array 'flights'
// sorting is in increasing order by price of flights
// bubble sort used

void sortFlightIdx(int flightIdx[], int nIdx, Flight flights[]);

////////////////////////////////////////
// 'bookFlight' books 'nSeats' seats on 'flight'
// updates remaining seats (if successful)
// returns true if successful
// returns false if not enough seats

bool bookFlight(Flight & flight, int nSeats);

/***********************************************
 *see function defnition in bookFlights.cpp for
 *function comments
 ***********************************************/

void upperCase(string &);
int returnDigit(char choice[]);

#endif

